package solutions.leetcode.easy

/**
 * @author lizhidong
 * <a href="https://leetcode.cn/problems/number-of-even-and-odd-bits/">2595. 奇偶位数</a>
 */
private class Solution2595 {
    fun evenOddBit(n: Int): IntArray {
        var flag = 0
        val answer = IntArray(2)
        var p = n
        while (p > 0) {
            if (p % 2 == 1) {
                answer[flag]++
            }
            flag = 1 - flag
            p /= 2
        }
        return answer
    }
}

fun main() {
    println(Solution2595().evenOddBit(2).toList())
}